﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using FwProject.ShoppingMall.Com;
using FwProject.ShoppingMall.Shop;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;

namespace FwProject.Shop.Dto
{
    /// <summary>
    /// 商品输入模型（）
    /// </summary>
    public class ShopProductCreateDto: EntityDto<Guid>
    {
        #region 商品基础信息
        [Display(Name = "商品宣传图片")]
        public string ImagePic { get; set; }

        [Display(Name = "商品分类")]
        public Guid ShopTypeid { get; set; }

        [Required]
        [Display(Name = "商品名称")]
        public string ProductName { get; set; }

        [Required]
        [Display(Name = "商品编号")]
        public string ProductNumber { get; set; }

        [Required]
        [Display(Name = "市场价格")]
        public decimal MarketPrice { get; set; } = 0m;

        [Display(Name = "计价单位")]
        public string Unit { get; set; }

        [Display(Name = "详情描述")]
        public string ProductDetails { get; set; }

        [Required]
        [Display(Name = "销售价")]
        public decimal SpcemarketPrice { get; set; } = 0m;

        [Required]
        [Display(Name = "成本价")]
        public decimal SpcecostPrice { get; set; } = 0m;

        [Display(Name = "是否上架")]
        public bool IsGrounding { get; set; }

        [Required]
        [Display(Name = "重量")]
        public float SpceWeight { get; set; } = 0;

        [Display(Name = "是否开启规格")]
        public bool SpceIsActive { get; set; }

        /// <summary>
        /// 销售模式
        /// </summary>
        [Display(Name ="销售模式")]
        public ShopProductFlag ShopProductFlag { get; set; }

        [Display(Name ="供应商")]
        public Guid ShopSupplierid { get; set; }
        #endregion

        #region 类型

        public ProductTypeDto ProductType { get; set; }
        #endregion

        #region 标签

        public List<ShopTagDto> ShopTags { get; set; }

        #endregion
    }

    #region MyRegion
    public class ProductTypeDto
    {
        /// <summary>
        /// 是否存在属性
        /// </summary>
        [Display(Name = "是否存在属性")]
        public bool Isflagattr { get; set; } = true;
        public List<ProductTypeAttrDto> Attrs { get; set; }

        /// <summary>
        /// 是否存在参数
        /// </summary>
        [Display(Name = "是否存在参数")]
        public bool Ispro { get; set; } = true;
        public List<ProductTypeParDto> Pars { get; set; }
 

        /// <summary>
        /// 是否和品牌关联
        /// </summary>
        [Display(Name = "是否和品牌关联")]
        public bool Isbrand { get; set; } = true;
        public IEnumerable<ProductTypeBrandDto> Brands { get; set; }
 
        /// <summary>
        /// 是否存在规格选项
        /// </summary>
        [Display(Name = "是否存在规格选项")]
        public bool IsSpec { get; set; } = false;
        public List<ProductSpceDto> Spces { get; set; }
    }
    public class ProductTypeParDto
    {
        public Guid? Id { get; set; }
        /// <summary>
        /// 参数组名称
        /// </summary>
        public string GroupName { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        public List<string> ParValus { get; set; }
    }

    public class ProductTypeBrandDto
    {
        /// <summary>
        /// 品牌Id
        /// </summary>
        public Guid BrandId { get; set; }
        /// <summary>
        /// 品牌名称
        /// </summary>
        public string BrandName { get; set; }
    }

    public class ProductTypeAttrDto
    {
        /// <summary>
        /// 属性名称
        /// </summary>
        public string AttrName { get; set; }

        /// <summary>
        /// 选择项
        /// </summary>
        public string Attrvalue { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; }
    }

    public class ProductSpceDto
    {
        public Guid Id { get; set; }
        /// <summary>
        /// 规格名称
        /// </summary>
        public string SpceName { get; set; }

        /// <summary>
        /// 规格类型
        /// </summary>
        public SpceTypeEnum SpceType { get; set; }

        /// <summary>
        /// 规格备注
        /// </summary>
        public string SpceNote { get; set; }

        /// <summary>
        /// 规格值
        /// </summary>
        public IEnumerable<SpceValuesDto> SpceValues { get; set; }


    }

    public class SpceValuesDto
    {


        public Guid Id { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        public string Spcevalueico { get; set; }
        /// <summary>
        /// 规格值
        /// </summary>
        public string Spcevalue { get; set; }

        /// <summary>
        /// 是否选中
        /// </summary>
        public bool IsSelected { get; set; } = false;
    }
    #endregion

    /// <summary>
    /// 修改
    /// </summary>
    [AutoMap(typeof(ShopProduct))]
    public class ShopProductEditDto:ShopProductCreateDto
    {
        public Guid? Brandid { get; set; }
        /// <summary>
        /// 商品对应规格
        /// </summary>
        public List<ShopProductSpceDto> ShopProductSpces { get; set; }
        /// <summary>
        /// 商品对应规格值
        /// </summary>
        public List<ShopProductSpceValueDto> ShopProductSpceValues { get; set; }

        /// <summary>
        /// SKU
        /// </summary>
        public List<ShopProductSkuDto> ShopProductSkus { get; set; }

        /// <summary>
        /// 属性
        /// </summary>
        public List<ShopProductAttrDto> ShopProductAttrs { get; set; }

        /// <summary>
        /// 参数
        /// </summary>
        public List<ShopProductParDto> ShopProductPars { get; set; }

        /// <summary>
        /// 标签
        /// </summary>
        public List<ShopProductTagDto> ShopProductTags { get; set; }

        /// <summary>
        /// 宣传图
        /// </summary>
        public List<ShopProductImagesDto> PicImages { get; set; }

        /// <summary>
        /// 详情图
        /// </summary>
        public List<ShopProductImagesDto> DetailsImages { get; set; }
    }

    public class ShopProductImagesDto
    {
        /// <summary>
        /// 文件名称
        /// </summary>
        public string FileName { get; set; }
        /// <summary>
        /// 路径
        /// </summary>
        public string Path { get; set; }
    }
}
